!function (e, $, mui) {
    "use strict";
	
	var config = {
	};
	// 定义页面
	var p = function(config) {
		var t = this;
		t.config = config;
		t.userInfo = null;
		t.element = {
			username: $('.username'),
			exit: $('#exit'),
			exitApp: $('#exit-app'),
			logout: $('#logout')
		};
		t.init();
	};
	
	var pt = p.prototype;
	
	// 页面初始化
	pt.init = function () {
		var t = this;
		t.userInit();
		// 监听
		t.listen();
		// 页面加载
		t.pageLoad();
	};
	
	// 用户信息初始化
	pt.userInit = function() {
		var t = this;
		t.userInfo = getLocalUserInfo();
	};
	
	// 事件监听
	pt.listen = function () {
		var t = this;
		t.element.exit.on('tap', function () {
			mui('#sheet1').popover('toggle');
		});
		$('#logout').on('tap', function () {
			userLogout();
		});
		$('#exit-app').on('tap', function () {
			plus.runtime.quit();
		});
	}
	
	// 列表初始化
	pt.pageLoad = function () {
		var t = this;
		t.element.username.html(userInfo.Pname);
	}

	
	mui.plusReady(function () {
		
		// 页面初始化
		e.page = new p(config);
		
		var tuichu = "再按一次退出程序";
		var backButtonPress = 0;

		// 关闭所有无用窗口
		clearAllWindows();
		plus.navigator.setStatusBarBackground('#2E9CFE');
		
		mui.back = function(event) {
			backButtonPress++;
			if(backButtonPress > 1) {
				var main = plus.android.runtimeMainActivity();
				main.moveTaskToBack(false);
				return false;
			} else {
				plus.nativeUI.toast(tuichu);
			}
			setTimeout(function() {
				backButtonPress = 0;
			}, 1000);
			return false;
		};
	});

}(window, $, mui);